import json
from Lib.system import money

from reference.day3 import list1


class Record:
    def __init__(self,date,order_id,money,provice):
        self.date=date
        self.order_id=order_id
        self.money=money
        self.provice=provice

    def __str__(self):
        return f"{self.date},{self.order_id},{self.money},{self.provice}"

class FileReader:

    def read_data(self) ->list[Record]:
        pass



class TextFileReader(FileReader):
    def __init__(self, path):
        self.path = path

    def read_data(self) ->list[Record]:
        f1=open(self.path,"r",encoding="UTF-8")
        list1 = []
        for x in f1.readlines():
            x=x.strip().split(",")
            record=Record(x[0],x[1],int(x[2]),x[3])
            list1.append(record)
        f1.close()
        return  list1
f2=TextFileReader("C:/Users\徐赛坤\Desktop\销数据.txt")
data1=f2.read_data()

class Text2(FileReader):
    def __init__(self, path):
        self.path = path

    def read_data(self) ->list[Record]:
        list1=[]
        f1=open(self.path,"r",encoding="UTF-8")
        for x in f1.readlines():
            drap=json.loads(x)
            record=Record(drap["date"],drap['order_id'],drap["money"],drap["provice"])
            list1.append(record)
        f1.close()
        return  list1
f3=Text2("C:/Users\徐赛坤\Desktop\售记录.txt")
data2=f3.read_data()
Data=data1+data2

data_dict={}
for x in Data:
    if x.date in data_dict.keys():
        data_dict[x.date]+=x.money
    else:
        data_dict[x.date]=money
print(data_dict)




